<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增api')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-account-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label"><span style="color: red; ">*</span>api账号名称：</label>
				<div class="col-sm-8">
					<input id="accountName" name="accountName" class="form-control" type="text" required>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" name="remark" class="form-control"></textarea>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    
    <script type="text/javascript">
		var prefix = ctx + "api/account"
		$("#form-account-add").validate({
			rules:{
				accountName:{
					required:true,
					remote: {
                        url: prefix + "/checkNameUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                        	accountName : function() {
                                return $.common.trim($("#accountName").val());
                            }
                        },
                        dataFilter: function(data, type) {
                        	return $.validate.unique(data);
                        }
                    }
				},
			},
			focusCleanup: true
		});
		
		function submitHandler() {
			if ($.validate.form()) {
				$.operate.save(prefix + "/add", $('#form-account-add').serialize());
	        }
	    }
	</script>
</body>
</html>
